/*
 * This class performs an sql query to add
 * events that are failed, every midnight,
 * and it also changes the completed field for joined plans
 * 
 * 
 * 
 */
package lauglog.util;

import java.util.TimerTask;
import java.sql.*;

/**
 *
 * @author Waseem Mir
 */
public class EventFailedRunner extends TimerTask{
    
    public void run(){
        /*
        //Initiate variables for database queries
        String url = "jdbc:mysql://localhost/lauglog";
        String dbUserName = "root";
        String dbPassword = "";
        String driver = "com.mysql.jdbc.Driver";
        Connection con = null;
        
        try{
            
            //Make the connection
            Class.forName(driver).newInstance();
            con = DriverManager.getConnection(url, dbUserName, dbPassword);
            
            //we have to get all plans that are not completed
            PreparedStatement userFriendsStatement = con.prepareStatement("SELECT UserId,DATE(StartDate) AS StartDate,Duration, PlanId FROM joined_plans WHERE Completed=0");
            userFriendsStatement.setInt(1, userID);
            userFriendsStatement.setInt(2, userID);
            ResultSet friendsRs = userFriendsStatement.executeQuery();
            
            while(friendsRs.next()){
                Friend f = new Friend();
                f.setFriendId(friendsRs.getInt("FriendId"));
                f.setFriendName(friendsRs.getString("UserName"));
                f.setProfilePicture("Pic");
                
                friends.add(f);
            }
            
            FriendsListBean friendsList = new FriendsListBean();
            friendsList.setFriendList(friends);
            
            HttpSession session = request.getSession();
            session.setAttribute("userFriends",friendsList);
            
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try{
                con.close();
            }catch(Exception e){
                
            }
        }*/
    }
    
}
